import math

class ElevatorClass():
    def __init__(self, elevatorNum, top=5, floor=0, bottom=0, DefaultFloor=0):
        self.floorDiff = int
        self.doorsOpen = False
        self.locX = int
        self.locY = int
        self.locRadius = int

        self.floorNaming = 0
        
        if floor <= top and floor >= bottom:
            self.floor = floor
            self.finalFloor = floor
        if top >= bottom:
            self.top = top
        if bottom <= top:
            self.bottom = bottom
        if DefaultFloor >= bottom and DefaultFloor <= top:
            self.defaultFloor = DefaultFloor

    def mutateFloor(self, newFloor):
        if newFloor > self.bottom and newFloor < self.top:
            self.floor = newFloor
            self.locY = newFloor * 10
            return 0
        else:
            return -1

    def mutateTop(self, newTop):
        if newTop > self.bottom:
            self.top = newTop
            if self.floor > self.top and self.defaultFloor > self.top:
                self.floor = self.top
            elif self.floor > self.top:
                self.floor = self.defaultFloor
            return 0
        else:
            return -1

    def mutateBottom(self, newBottom):
        if newBottom < self.top:
            self.bottom = newBottom
            if self.floor < self.bottom and self.defaultFloor < self.bottom:
                self.floor = newBottom
            elif self.floor < self.bottom:
                self.floor = self.defaultFloor
            return 0
        else:
            return -1

    def mutateDefault(self, newDefault):
        if newDefault >= self.bottom and newDefault <= self.top:
            self.defaultFloor = newDefault
            return 0
        else:
            return -1

    def mutateFloorDiff(self, Diff):
        if math.fabs(Diff) < (self.top-self.floor) or math.fabs(Diff) < (self.floor - self.bottom):
            self.floorDiff = Diff
            return 0
        else:
            return -1

    def mutateFloorNaming(self, newFloorNaming):
        self.floorNaming = newFloorNaming

    def viewFloor(self):
        return self.floor

    def viewTop(self):
        return self.top

    def viewBottom(self):
        return self.bottom

    def viewDefault(self):
        return self.defaultFloor

    def viewFloorDiff(self):
        return self.floorDiff

    def viewFloorNaming(self):
        return self.floorNaming

    def viewFinalFloor(self):
        return self.finalFloor

    def callToFloor(self, callingFloor):
        self.finalFloor = callingFloor
        if self.finalFloor < self.floor:
            self.floor -= 1
        elif self.finalFloor > self.floor:
            self.floor += 1

    def goToFloor(self):
        if self.finalFloor <= self.top and self.finalFloor >= self.bottom:
            self.floorDiff = self.finalFloor - self.floor
            self.floor = self.finalFloor
            return self.floorDiff
        else:
            return -1000

    def move(self, moveDist = 10):
        if self.floorDiff != 0:
            self.doorsOpen = False
            if self.floorDiff < 0:
                self.locY += moveDist
                self.floorDiff += 1
                return -1
            elif self.floorDiff > 0:
                self.locY -= moveDist
                self.floorDiff -= 1
                return 1
            else:
                self.doorsOpen = True
                return 0
            return -2
